//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------

using GameFramework;

internal sealed partial class EventPool<T> where T : BaseEventArgs
{
    /// <summary>
    /// 事件结点。
    /// </summary>
    private sealed class Event : IReference
    {
        private object m_Sender;
        private T m_EventArgs;

        public Event()
        {
            m_Sender = null;
            m_EventArgs = null;
        }

        public object Sender
        {
            get
            {
                return m_Sender;
            }
        }

        public T EventArgs
        {
            get
            {
                return m_EventArgs;
            }
        }

        public static Event Create(object sender, T e)
        {
            Event eventNode = ReferencePool.Acquire<Event>();
            eventNode.m_Sender = sender;
            eventNode.m_EventArgs = e;
            return eventNode;
        }

        public void Clear()
        {
            m_Sender = null;
            m_EventArgs = null;
        }
    }
}

